
#include "vty_history.hpp"


int vty_history::prev(reference np) 
{ 
    string_ptr ptr;
    if (is_top()) return -1;
    PDBG("CP: %d\n",_cp);
    ptr = _vector[++_cp];
    PDBG("prev: %s\n", ptr->c_str());
    np = ptr;
    return 0;
};

int vty_history::next(reference pp) 
{ 
    string_ptr ptr;
    if (is_bottom()) return -1;
    if (_cp == 0) return -1;
    ptr = _vector[--_cp];
    PDBG("CP: %d\n",_cp);
    PDBG("next: %s\n", ptr->c_str());
    pp = ptr;
    return 0;
}; 

void vty_history::push(string_ptr ptr) 
{ 
    if (full()) return;
    _top++; 
    _vector.push_front(ptr); 
    PDBG("push: %s\n", ptr->c_str());
}; 

